
<div class="widthauto account_header" id="accountHead">
  <div class="pub_wid">
      <div class="lf"><a href="/"><img src="/static/index/public/images/logo_b.png" /></a></div>

      <div v-if="status" class="rg account_head">欢迎您，{{name}}<span>|</span><a @click="logout()">退出登录</a></div>

      <div v-else class="rg account_head">还没有账号<span>|</span><a href="/index/member/index">去注册</a></div>
  </div>
</div>
<script>
    var vmAccount_head = new Vue({
        el:'#accountHead',
        data:{
            phone:'',
            status:false,
            name:''
        },
        methods:{
            getMember:function (phone) {
                var el = this;
                var postData = {
                    'phone':phone,
                }
                AjaxPost(postData,'/index/member/getMemberByPhone').then((response)=>{
                    if(response.result !=null){
                        el.status = true;
                        el.name =response.result.nickname  || response.result.phone
                    }else {
                        el.status = false
                    }

                })
            },
            logout:function () {
                AjaxPostFree('/index/member/memberLogout').then((response)=>{
                    console.log(response)
                    localStorage.clear();
                    // localStorage.removeItem("memberPhone");
                    // localStorage.removeItem("memberId")
                    // localStorage.removeItem("member_category")
                    // localStorage.removeItem("member_grade")
                    // localStorage.removeItem("member_status");
                    window.location.href='/index/member/login'
                })
            }
        },
        mounted(){
            if(localStorage.getItem("memberPhone") != null){
                this.getMember(localStorage.getItem("memberPhone"))
            }
            // if(localStorage.getItem('memberId')){
            //     if(localStorage.getItem('member_category')){
            //         if(localStorage.getItem('member_category')==1){
            //             window.location.href='/index/consignor/index'
            //         }else if(localStorage.getItem('member_category')==2){
            //             window.location.href='/index/logistics/index'
            //         }else {
            //             window.location.href='/index/member/loginSuccess'
            //         }
            //     }else {
            //         window.location.href='/index/member/loginSuccess'
            //     }
            // }else{
            //     window.location.href='/index/member/login'
            // }


        }
    })
</script>